<?php
/*
 * Author: ThanhTV
 * Date create: Tue,05/04/2011
 * Email:thanhtran@vietnambiz.com
 * Desc: Home_model - HaiPhat Hair Website
 */

class Home_model extends MY_Model{

    function Home_model(){
        parent::MY_Model();
    }

    function get_count_cat($cat_id)
    {
        $this->db->select("count(id) as m")->from('articles')->where('id_category', $cat_id);
        $rs = $this->db->get()->row();
        $this->db->select("count(id) as a")
               ->from('articles')               
               ->where(array('status'=>'yes'));
        $rs2 = $this->db->get()->row();
        return $rs->m." / <font color='gray'>".$rs2->a."</font>";
    }

    function get_count_all_cat($active="")
    {
         $this->db->select("count(id) as m")->from('categories');
         if(!empty($active)){
	      	$this->db->where("status",$active);
	 }
         $rs = $this->db->get()->row();
         return $rs->m;
    }
    
    function get_count_all_articles()
    {

        $this->db->select("count(id) as m")->from('articles');
        $rs = $this->db->get()->row();
        return $rs->m;
    }
    
    function get_count_articles_status($mode)
    {
        $this->db->select("count(id) as m")->from('articles')->where('status',$mode);
        $rs = $this->db->get()->row();
        return $rs->m;
    }
}